Skip to content

CFE-4681: timer_policy support for classes: promises#6167

Open
nickanderson wants to merge 1 commit into
cfengine:masterfrom
nickanderson:CFE-4681/timer-policy-classes-promises
Open

CFE-4681: timer_policy support for classes: promises#6167
nickanderson wants to merge 1 commit into
cfengine:masterfrom
nickanderson:CFE-4681/timer-policy-classes-promises

Conversation

@nickanderson

@nickanderson nickanderson commented Jun 5, 2026

Copy link
Copy Markdown
Member

Summary

  • Add timer_policy attribute to classes: promise type, allowing users to control whether a persistent class timer resets on re-evaluation (reset) or preserves the original expiry (absolute)
  • Default timer_policy for classes: promises is absolute (PRESERVE) for backward compatibility — historically these promises skip re-evaluation when the class is already defined, so the timer was never reset
  • Bypass the ExpandDeRefPromise skip when timer_policy => "reset" is explicitly set with persistence > 0, allowing the promise to reach VerifyClassPromise so the DB timer can be updated
  • Add second-layer bypass in VerifyClassPromise for the case where EvalClassExpression returns false (class already in context from persistent DB) but timer_policy is reset
  • Fix ValueSizeDB key length to include null terminator (strlen+1), matching ReadDB/WriteDB conventions

Test plan

  • Manual test: timer_policy => "absolute" creates class with "policy preserve", second run skips the promise
  • Manual test: timer_policy => "reset" creates class with "policy reset", second run resets the timer
  • Acceptance test persistent_timer_policy.cf: verifies absolute/preserve log output
  • Acceptance test persistent_timer_policy_reset.cf: verifies timer reset across two agent runs
  • CI acceptance tests pass

Ticket: CFE-4681

🤖 Generated with Claude Code

@cf-bottom

Copy link
Copy Markdown

Thank you for submitting a PR! Maybe @craigcomstock can review this?

@nickanderson nickanderson force-pushed the CFE-4681/timer-policy-classes-promises branch from af21356 to 1ff08f3 Compare June 7, 2026 23:49
- Flip default timer_policy to "absolute" (PRESERVE) for backward
  compatibility: classes: promises historically skip re-evaluation
  when the class is already defined, so the timer was never reset.
- Bypass the ExpandDeRefPromise skip when timer_policy is explicitly
  set to "reset" with persistence > 0, allowing the promise to reach
  VerifyClassPromise so the DB timer can be updated.
- Add second-layer bypass in VerifyClassPromise for the case where
  EvalClassExpression returns false (class already in context) but
  timer_policy is "reset" — write the DB entry to reset the timer.
- Clean up acceptance tests: use imported bodies (in_shell, always),
  regline() instead of returnszero+grep, $(G.testdir), files promises
  with delete => tidy, and add test metadata.
- Add timer_policy_reset acceptance test verifying the timer resets
  across agent runs.

Ticket: CFE-4681
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@nickanderson nickanderson force-pushed the CFE-4681/timer-policy-classes-promises branch from 1ff08f3 to 41cb477 Compare June 7, 2026 23:57
@nickanderson

Copy link
Copy Markdown
Member Author

@cf-bottom jenkins please

@cf-bottom

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants